cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

find_package(LibL2 REQUIRED)
include_directories(${LibL2_INCLUDE_DIRS})
set(LIBS ${LibL2_LIBRARIES})

find_package(LibHdf5utils REQUIRED)
include_directories(${LibHdf5utils_INCLUDE_DIRS})
list(APPEND LIBS ${LibHdf5utils_LIBRARIES})

find_package(GeoTIFF REQUIRED)
include_directories(${GeoTIFF_INCLUDE_DIRS})
list(APPEND LIBS ${GeoTIFF_LIBRARIES})

find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIRS})
list(APPEND LIBS ${PNG_LIBRARIES})

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    find_package(X11 REQUIRED)
    include_directories(${X11_INCLUDE_DIR})
    list(APPEND LIBS ${X11_LIBRARIES})
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

add_executable(l2mapgen
  main_l2mapgen.c
  l2mapgen_input.c
  mipolyutil.c
)

target_link_libraries(l2mapgen ${LIBS})

install (TARGETS l2mapgen DESTINATION bin)

